# -*- coding: utf-8 -*-


import pygame


class Cell(object):
    """墙壁和道路的基类
    """

    def __init__(self, screen, color=pygame.Color('white')):
        self.width = 0
        self.height = 0
        self._color = color
        self._default_color = color

        self.screen = screen

    def draw(self, x, y, width=0, height=0):
        if self.will_cell_overflow(x, y, width, height) is False:
            # print u"画Cell方块: ", x, y, width, height
            pygame.draw.rect(self.screen, self._color, (x, y, width,
                height))

    def will_cell_overflow(self, x, y, width, height):
        screen_width, screen_height = self.screen.get_size()
        # print u"右下方的点：x: %d, y: %d" % (x + width, y + height)
        if (x + width) > screen_width or (y + height) > screen_height:
            print "Point overflow, Do not draw !"
            return True
        return False

    def get_size(self):
        return self.width, self.height

    def get_width(self):
        return self.width

    def get_height(self):
        return self.height

    def get_curr_color(self):
        """
        获取当前使用什么颜色在画
        """
        return self._color

    def change_color(self, color):
        """
        改变画的颜色
        """
        self._color = color

    def set_default_color(self):
        self._color = self._default_color